import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'layout',
    component: layout,
    redirect: '/home',
    children: [{
            path: '/home',
            name: 'home',
            component: () =>
                import ('../views/home/index.vue'),
            meta: {
                title: '综合信息',
            },
        }, {
            path: '/map1',
            name: 'map1',
            component: () =>
                import ('../views/map1/index.vue'),
            meta: {
                title: '国内疫情气泡图',
            },
        },
        {
            path: '/map2',
            name: 'map2',
            component: () =>
                import ('../views/map2/index.vue'),
            meta: {
                title: '全球疫情气泡图',
            },
        },
        {
            path: '/map3',
            name: 'map3',
            component: () =>
                import ('../views/map3/index.vue'),
            meta: {
                title: '国内疫情热力图',
            },
        },
        {
            path: '/map4',
            name: 'map4',
            component: () =>
                import ('../views/map4/index.vue'),
            meta: {
                title: '全球疫情热力图',
            },
        }
    ]
}]



const router = new VueRouter({
    routes
})

router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

export default router